import java.util.Arrays;
import java.util.Random;

public class Test {
    public static void main(String[] args) {
       int[] array = crateArray();
       testInsert(array);
       testShellSort(array);
       testSelectSort(array);
       testQuickSort(array);
       testMergerSort(array);
       testcountSort(array);
       bubbleSort(array);
    }
    public static int[] crateArray(){
        int[] array = new int[10];
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(100000);
        }
        return array;
    }

    public static void testInsert(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.insetSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("直接插入排序耗时："+(endTime-startTime));
    }

    public static void testShellSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.shellSort (array);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗时："+(endTime-startTime));
    }
    public static void testSelectSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.selectSort (array);
        long endTime = System.currentTimeMillis();
        System.out.println("选择排序耗时："+(endTime-startTime));
    }

    public static void testQuickSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.quickSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序耗时："+(endTime-startTime));
    }

    public static void testMergerSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.mergerSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("归并排序耗时："+(endTime-startTime));
    }

    public static void bubbleSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.bubbleSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("冒泡排序耗时："+(endTime-startTime));
    }

    public static void testcountSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.countSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("计数排序耗时："+(endTime-startTime));
    }
}
